<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<h1>GET</h1>
		<div id="div_01">
			<label id='lab01'>获取当前日期和时间</label>
			<br/>
			<button type="button" onclick="GetTime();">获取</button>
		</div>
		<br />
		<div id="div_02">
			<label id='lab02'>随机一句名言</label>
			<br/>
			<button type="button" onclick="Saying();">获取</button>
		</div>
		<br />
		<div id="div_03">
			<label id='lab03'>获取诗词列表-包含作者信息</label>
			<br/>
			<button type="button" onclick="Poetry();">获取</button>
		</div>
		<br />
		<div id="div_04">
			<label id='lab04'>获取诗词列表-包含作者信息</label>
			<br/>
			<button type="button" onclick="Author();">获取</button>
		</div>
		<br />
		<div id="div_05">
			<label id='lab05'>段子详情</label>
			<br/>
			<button type="button" onclick="Weather();">获取</button>
		</div>
		<br />
		
	</body>
	<script type="text/javascript">
		
		function Weather(){
			var TimeAjax = new XMLHttpRequest();
			var url = '?sid=28654780';
			TimeAjax.open('GET','https://api.apiopen.top/getSingleJoke'+url);
			TimeAjax.send();
			TimeAjax.onreadystatechange = function(){
				if(TimeAjax.status==200 && TimeAjax.readyState==4){
					document.getElementById('lab05').innerText=TimeAjax.responseText;
					var obj = JSON.parse(TimeAjax.responseText);
					console.log(obj);
				}
			}
		}
		function Author(){
			var TimeAjax = new XMLHttpRequest();
			TimeAjax.open('GET','http://poetry.apiopen.top/poetryAuthor?count=2&page=1&name=李白');
			TimeAjax.send();
			TimeAjax.onreadystatechange = function(){
				if(TimeAjax.status==200 && TimeAjax.readyState==4){
					document.getElementById('lab04').innerText=TimeAjax.responseText;
					var obj = JSON.parse(TimeAjax.responseText);
					console.log(obj);
				}
			}
		}
		function Poetry(){
			var TimeAjax = new XMLHttpRequest();
			TimeAjax.open('GET','http://poetry.apiopen.top/poetryFull?count=2&page=1');
			TimeAjax.send();
			TimeAjax.onreadystatechange = function(){
				if(TimeAjax.status==200 && TimeAjax.readyState==4){
					document.getElementById('lab03').innerText=TimeAjax.responseText;
					var obj = JSON.parse(TimeAjax.responseText);
					console.log(obj);
				}
			}
		}
		function Saying(){
			var TimeAjax = new XMLHttpRequest();
			TimeAjax.open('GET','http://poetry.apiopen.top/sentences');
			TimeAjax.send();
			TimeAjax.onreadystatechange = function(){
				if(TimeAjax.status==200 && TimeAjax.readyState==4){
					document.getElementById('lab02').innerText=TimeAjax.responseText;
					var obj = JSON.parse(TimeAjax.responseText);
					console.log(obj);
				}
			}
		}
		function GetTime(){
			var TimeAjax = new XMLHttpRequest();
			TimeAjax.open('GET','http://poetry.apiopen.top/getTime');
			TimeAjax.send();
			TimeAjax.onreadystatechange = function(){
				if(TimeAjax.status==200 && TimeAjax.readyState==4){
					document.getElementById('lab01').innerText=TimeAjax.responseText;
					var obj = JSON.parse(TimeAjax.responseText);
					console.log(obj);
				}
			}
		}
	</script>
</html>
